﻿using Abp.Application.Services.Dto;
using Abp.AutoMapper;
using SingleUserMall.Items;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static SingleUserMall.Dividends.Dividend;
using static SingleUserMall.Items.Item;

namespace SingleUserMall.Orders.VO
{
    /// <summary>
    /// 订单元素
    /// </summary>
    [AutoMapFrom(typeof(OrderDetail))]
    public class OrderDetailVO : EntityDto<long>
    {
        internal Item inItem { get; set; }
        internal ItemSpec inItemSpec { get; set; }
        /// <summary>
        /// 商品id
        /// </summary>
        public long? ItemId => inItem?.Id;
        /// <summary>
        /// 商品规格id
        /// </summary>
        public long? ItemSpecId => inItemSpec?.Id;
        /// <summary>
        /// 规格或商品图片
        /// </summary>
        public string Picture => inItemSpec?.Picture ?? inItem?.Picture;
        /// <summary>
        /// 商品名称
        /// </summary>
        public string Name => inItem?.Name;
        /// <summary>
        /// 规格
        /// </summary>
        public string Spec => inItemSpec?.Spec;
        /// <summary>
        /// 分红期数
        /// </summary>
        public int? NumberPeriods =>inItem?.NumberPeriods;

        /// <summary>
        /// 期限（月）
        /// </summary>
        public int? Timelimit => inItem?.Timelimit;

        /// <summary>
        /// 分红比例
        /// </summary>
        public decimal? DividendAmount => inItem?.DividendAmount;

        /// <summary>
        /// 分红比例显示界面
        /// </summary>
        public string DividendAmountView { get; set; }

        /// <summary>
        /// 分红比例显示界面 年分红
        /// </summary>
        public string DividendAmountViewByYear { get; set; }

        /// <summary>
        /// 分红类型
        /// </summary>
        public DividendType? DividendTypes => inItem?.DividendTypes;

        /// <summary>
        /// 每天分红收益
        /// </summary>
        public decimal DailyProfit { get; set; }

        /// <summary>
        /// 已分红天数
        /// </summary>
        public int DividendDay { get; set; }

        /// <summary>
        /// 累计分红收益
        /// </summary>
        public decimal Profit { get; set; }

        /// <summary>
        /// 单价
        /// </summary>
        public decimal Price { get; set; }
        /// <summary>
        /// 数量
        /// </summary>
        public int Qty { get; set; }
        /// <summary>
        /// 价格合计
        /// </summary>
        public decimal TotalPrice => Price * Qty;
        /// <summary>
        /// 运费
        /// </summary>
        public decimal Freight { get; set; }
        /// <summary>
        /// 客服电话
        /// </summary>
        public string CustomerServicePhone { get; set; }
    }
}
